<?php
use_helper('I18N');
?>

<style>
    .column {
        width: 50%;
        float: left;
        padding-bottom: 100px;
    }

    .portlet {
        margin: 0 1em 1em 0;
    }

    .portlet-header {
        margin: 0.3em;
        padding-top: 5px;
        padding-bottom: 5px;
        padding-left: 0.5em;
    }

    .portlet-header .ui-icon {
        float: right;
    }

    .portlet-content {
        padding: 1em;
    }

    .ui-sortable-placeholder {
        border: 1px dotted black;
        visibility: visible !important;
        height: 50px !important;
    }

    .ui-sortable-placeholder * {
        visibility: hidden;
    }
</style>
<script type="text/javascript">
    var datagrid = null;
    var datagridEShare = null;
    var datagridSellEShare = null;
    $(function() {
        $(".column").sortable({
                    connectWith: ".column"
                });
        //$(".column").disableSelection();
        datagrid = $("#datagrid").r9jasonDataTable({
                    // online1DataTable extra params
                    "idTr" : true, // assign <tr id='xxx'> from 1st columns array(aoColumns);
                    "extraParam" : function(aoData) { // pass extra params to server
                        aoData.push({ "name": "statusCode", "value": $("#search_combo_statusCode").val()  });
                    },
                    "reassignEvent" : function() { // extra function for reassignEvent when JSON is back from server
                    },

                    // datatables params
                    "bLengthChange": true,
                    "bFilter": false,
                    "bProcessing": true,
                    "bServerSide": true,
                    "bAutoWidth": false,
                    "sAjaxSource": "<?php echo url_for('admin/withdrawList') ?>",
                    "sPaginationType": "full_numbers",
                    "aoColumns": [
                        { "sName" : "withdraw.withdraw_id", "bVisible" : false},
                        { "sName" : "withdraw.dist_id", "bVisible" : false},
                        { "sName" : "dist.distributor_code",  "bSortable": true, "fnRender": function ( oObj ) {
                          return "<a id='editLink' href='<?php echo url_for('finance/withdrawalEdit?q=dsf453fsdfasf1sxfsdfs&withdrawId=') ?>/" + oObj.aData[0] + "'>" + oObj.aData[2] + "</a>";
                        }},
                        { "sName" : "dist.full_name",  "bSortable": true},
                        { "sName" : "withdraw.deduct",  "bSortable": true},
                        { "sName" : "withdraw.amount",  "bSortable": true},
                        { "sName" : "withdraw.status_code",  "bSortable": true},
                        { "sName" : "withdraw.created_on",  "bSortable": true}
                        , { "sName" : "dist.ic",  "bVisible": false}
                        , { "sName" : "dist.email",  "bVisible": false}
                        , { "sName" : "dist.contact",  "bVisible": false}
                        , { "sName" : "dist.bank_name",  "bVisible": false}
                        , { "sName" : "dist.bank_acc_no",  "bVisible": false}
                        , { "sName" : "dist.bank_holder_name",  "bVisible": false}
                        , { "sName" : "dist.rank_code",  "bVisible": false}
                        , { "sName" : "withdraw.remarks",  "bVisible": false}
                        , { "sName" : "withdraw.dist_id",  "bVisible": true}
                    ]
                });

        datagridEShare = $("#datagridEShare").r9jasonDataTable({
                    // online1DataTable extra params
                    "idTr" : true, // assign <tr id='xxx'> from 1st columns array(aoColumns);
                    "extraParam" : function(aoData) { // pass extra params to server
                        aoData.push({ "name": "filterUsername", "value": $("#search_username").val()  });
                        aoData.push({ "name": "q", "value": $("#queryDate").val()  });
                    },
                    "reassignEvent" : function() { // extra function for reassignEvent when JSON is back from server
                    },

                    // datatables params
                    "bLengthChange": true,
                    "bFilter": false,
                    "bProcessing": true,
                    "bServerSide": true,
                    "bAutoWidth": false,
                    "sAjaxSource": "<?php echo url_for('admin/dailySalesList') ?>",
                    "sPaginationType": "full_numbers",
                    "aoColumns": [
                        { "sName" : "dist.distributor_code", "bVisible" : false},
                        { "sName" : "dist.distributor_code",  "bSortable": true},
                        { "sName" : "ecash.ECASH_SUM",  "bSortable": true},
                        { "sName" : "maintenance.MAINTENANCE_SUM",  "bSortable": true},
                        { "sName" : "eshare.ESHARE_SUM",  "bSortable": true}
                    ]
                });

        datagridSellEShare = $("#datagridSellEShare").r9jasonDataTable({
                    // online1DataTable extra params
                    "idTr" : true, // assign <tr id='xxx'> from 1st columns array(aoColumns);
                    "extraParam" : function(aoData) { // pass extra params to server
                        aoData.push({ "name": "filterUsername", "value": $("#search_sellUsername").val()  });
                        aoData.push({ "name": "q", "value": $("#querySellDate").val()  });
                    },
                    "reassignEvent" : function() { // extra function for reassignEvent when JSON is back from server
                    },

                    // datatables params
                    "bLengthChange": true,
                    "bFilter": false,
                    "bProcessing": true,
                    "bServerSide": true,
                    "bAutoWidth": false,
                    "sAjaxSource": "<?php echo url_for('admin/dailySellShareList') ?>",
                    "sPaginationType": "full_numbers",
                    "aoColumns": [
                        { "sName" : "dist.distributor_code", "bVisible" : false},
                        { "sName" : "dist.distributor_code",  "bSortable": true},
                        { "sName" : "ecash.ECASH_SUM",  "bSortable": true},
                        { "sName" : "eshare.ESHARE_SUM",  "bSortable": true}
                    ]
                });

        $("#queryDate").datepicker({
                    dateFormat: "yy-mm-dd"
                    , onSelect: function(dateText, inst) {
                        datagridEShare.fnDraw();
                    }
                });
        $("#querySellDate").datepicker({
                    dateFormat: "yy-mm-dd"
                    , onSelect: function(dateText, inst) {
                        datagridSellEShare.fnDraw();
                    }
                });
    });
</script>

<div class="demo" style="padding:6px">
    <div class="column">
        <div class="portlet">
            <div class="portlet-header">e-Share Amount</div>
            <div class="portlet-content">
                <table cellpadding="3" cellspacing="3" width="100%">
                    <tr>
                        <td><strong>Total e-Share Amount (Sell)</strong></td>
                        <td align="right"><?php echo number_format($totalShareSoldValue, 2); ?> USD</td>
                    </tr>
                    <tr>
                        <td><strong>Current e-Share Price</strong></td>
                        <td align="right"><?php echo number_format($eshareSell, 2); ?></td>
                    </tr>
                    <tr>
                        <td><strong>Next Increment Amount</strong></td>
                        <td align="right"><?php echo number_format($nextLevelVolumeNeeded, 2); ?> USD</td>
                    </tr>
                    <tr>
                        <td><strong>Next Increment e-Cash Needed</strong></td>
                        <td align="right"><?php echo number_format($nextLevelEcashNeeded, 2); ?> USD</td>
                    </tr>
                    <tr>
                        <td>
                            <strong><?php echo __('Daily Shares Trading Volume (Buy)', null, "goldTrading") ?>:</strong>
                        </td>
                        <td align="right">
                            <?php //echo number_format($eshareTradingDto->getDailySharesTradingVolumeBuy(),0)?> USD
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <strong><?php echo __('Daily Shares Trading Volume (Sell)', null, "goldTrading") ?>:</strong>
                        </td>
                        <td align="right">
                            <?php //echo number_format($eshareTradingDto->getDailySharesTradingVolumeSell(),0)?> USD
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <strong><?php echo __('Monthly Shares Trading Volume (Buy)', null, "goldTrading") ?>:</strong>
                        </td>
                        <td align="right">
                            <?php //echo number_format($eshareTradingDto->getMonthlySharesTradingVolumeBuy(),0)?> USD
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <strong><?php echo __('Monthly Shares Trading Volume (Sell)', null, "goldTrading") ?>:</strong>
                        </td>
                        <td align="right">
                            <?php //echo number_format($eshareTradingDto->getMonthlySharesTradingVolumeSell(),0)?> USD
                        </td>
                    </tr>
                </table>
            </div>
        </div>

        <div class="portlet">
            <div class="portlet-header">Withdrawal</div>
            <div class="portlet-content">
                <table class="display" id="datagrid" border="0" width="100%" cellpadding="0" cellspacing="0">
                    <thead>
                    <tr>
                        <th>withdrawal id [hidden]</th>
                        <th>dist id [hidden]</th>
                        <th width="5%">Shareholder</th>
                        <th width="5%">Name</th>
                        <th width="30%">Withdraw</th>
                        <th width="50%">Total Amount</th>
                        <th width="15%">Status</th>
                        <th width="15%">Date</th>
                        <th width="15%">IC</th>
                        <th width="15%">Email</th>
                        <th width="15%">Contact No</th>
                        <th width="15%">Bank Name</th>
                        <th width="15%">Bank Account No</th>
                        <th width="15%">Bank Holder Name</th>
                        <th width="15%">Rank Code</th>
                        <th width="15%">Remarks</th>
                        <th width="15%">Group Leader</th>
                    </tr>
                    <tr>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td>
                            <select id="search_combo_statusCode" style="width: 50px">
                                <option value="PENDING">PENDING</option>
                                <option value="PROCESSING">PROCESSING</option>
                                <option value="REJECTED">REJECTED</option>
                                <option value="PAID">PAID</option>
                            </select>
                        </td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>

    </div>

    <div class="column">
        <div class="portlet">
            <div class="portlet-header">Daily e-Share Sales</div>
            <div class="portlet-content">
                <table cellpadding="3" cellspacing="3" width="100%">
                    <tr>
                        <td>Date</td>
                        <td>
                            <input size="10" type="text" id="queryDate" value="<?php echo date('Y-m-d');?>"/>
                        </td>
                    </tr>
                </table>
                <table class="display" id="datagridEShare" border="0" width="100%" cellpadding="0" cellspacing="0">
                    <thead>
                    <tr>
                        <th>id [hidden]</th>
                        <th width="5%">Shareholder</th>
                        <th width="30%">e-Cash</th>
                        <th width="50%">Maintenance</th>
                        <th width="15%">Total shares</th>
                    </tr>
                    <tr>
                        <td></td>
                        <td><input title="" size="10" type="text" id="search_username" value="" class="search_init"/>
                        </td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>

        <div class="portlet">
            <div class="portlet-header">Daily e-Share Sell</div>
            <div class="portlet-content">
                <table cellpadding="3" cellspacing="3" width="100%">
                    <tr>
                        <td>Date</td>
                        <td>
                            <input size="10" type="text" id="querySellDate" value="<?php echo date('Y-m-d');?>"/>
                        </td>
                    </tr>
                </table>
                <table class="display" id="datagridSellEShare" border="0" width="100%" cellpadding="0" cellspacing="0">
                    <thead>
                    <tr>
                        <th>id [hidden]</th>
                        <th width="5%">Shareholder</th>
                        <th width="30%">e-Cash</th>
                        <th width="15%">Total shares</th>
                    </tr>
                    <tr>
                        <td></td>
                        <td><input title="" size="10" type="text" id="search_sellUsername" value="" class="search_init"/>
                        </td>
                        <td></td>
                        <td></td>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>
    </div>
</div>
